home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 3032.ZIP / RLIB20.ZIP / RL_CENTE.PRG < prev    next >
Text File  |  1989-02-18  |  907b  |  31 lines

  1. * Function: CENTER
  2. * Author..: Richard Low
  3. * Syntax..: CENTER( [exp<N>,] exp<C> )
  4. * Returns.: Column number to center <expC> on an 80 column monitor.
  5. *           If <expN> is specified, it displays exp<C> centered on
  6. *           row exp<N>.
  7.  
  8. FUNCTION CENTER
  9. PARAMETERS p1, p2
  10.  
  11. DO CASE
  12.    *-- if 1st parameter is character, no row number given
  13.    CASE TYPE('p1') = 'C'
  14.       *-- just return column to center, making sure its positive
  15.       RETURN MAX( INT((80-LEN(p1))/2), 0 )
  16.  
  17.    *-- if 1st parm is numeric, and 2nd parm is character
  18.    CASE TYPE('p1') = 'N' .AND. TYPE('p2') = 'C'
  19.       *-- make sure it is in range 0 to 24
  20.       IF p1 >= 0 .AND. p1 <= 24
  21.          *-- say it on screen
  22.          @ p1,(80-LEN(p2))/2 SAY p2
  23.       ENDIF
  24.       *-- and return value (make sure it is positive
  25.       RETURN MAX( INT((80-LEN(p2))/2), 0 )
  26.  
  27. ENDCASE
  28.  
  29. *-- otherwise bad parms
  30. RETURN (0)
  31.